package cn.hy.face.common.enums;

/**
 * @program: face
 * @author: qingxiangen
 * @create: 2019-09-05 10:22
 * @description: 数据状态枚举
 **/
public enum FaceStatusEnum {
    
    NO_UPLOAD((byte) 0, "未上传"),

    CHECK_SUCCESS((byte) 1, "校验成功"),

    CHECKING((byte) 2, "校验中"),

    CHECK_FAIL((byte) 3, "校验失败");
    
    private byte code;

    private String desc;

    FaceStatusEnum() {
    }

    FaceStatusEnum(byte code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    /**
     * 存在记录
     * @param code
     * @return
     */
    public static boolean hasRecord(Byte code){
        if(code == null || code.byteValue() == NO_UPLOAD.getCode()){
            return false;
        }
        return true;
    }


    /**
     * 根据code获取枚举
     * @param code
     * @return
     */
    public static FaceStatusEnum getEnumByCode(Byte code){
        return getEnumByCode(code == null ? -1 : code.byteValue());
    }

    /**
     * 根据code获取枚举
     * @param code
     * @return
     */
    public static FaceStatusEnum getEnumByCode(byte code){
        for (FaceStatusEnum e:  FaceStatusEnum.values()) {
            if(code == e.getCode()){
                return e;
            }
        }
        return NO_UPLOAD;
    }

    public byte getCode() {
        return code;
    }

    public void setCode(byte code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
    
}
